//
//  SEMacro.h
//  SleepingElf
//
//  Created by karong on 2023/6/7.
//

#ifndef SEMacro_h
#define SEMacro_h

typedef void(^EmptyBlock)();
typedef void(^AnyObjectBlock)(id obj);
typedef void(^ArrayBlock)(NSArray * array);
typedef void(^DictionaryBlock)(NSDictionary * dict);
typedef void(^StringBlock)(NSString * string);
typedef void(^IntegerBlock)(NSInteger integer);
typedef void(^ArrayDictionaryBlock)(NSArray *array, NSDictionary *dict);


#define WeakSelf __weak typeof(self) weakSelf = self;

// 屏幕
#define SEScreenWidth        [UIScreen mainScreen].bounds.size.width
#define SEScreenHeight       [UIScreen mainScreen].bounds.size.height
#define SEStatusBarHeight       [[UIApplication sharedApplication] statusBarFrame].size.height
#define SESafeAreaBottomHeight  [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom

// 设备
#define SEIsiPhoneX       (int)((SEScreenHeight/SEScreenWidth)*100) == 216.f

#ifdef DEBUG_ON
#define WLog(string, ...) NSLog(@"\n🐹%@  第%d行  %s\n🐹%@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__, [NSString stringWithFormat:(string), ##__VA_ARGS__])
#else
#define WLog(string, ...)
#endif

// 字符串格式化
#define SESF(format, ...) ([NSString stringWithFormat:(format), ##__VA_ARGS__])
// 字符串非空判断
#define SEIsNullOrEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || str.length <= 0)
// 字符串空保护
#define SEEmptyStr(str) SEIsNullOrEmpty(str) ? @"" : str
// 读取本地圖片
#define SEIMG(file) ([UIImage imageNamed:(file)])
#define appUserDefaults         [NSUserDefaults standardUserDefaults]
// 默認圖片
#define SEPlaceholderImage [UIImage imageNamed:@"icon_music_default"]
#define SEUserPlaceholderImage [UIImage imageNamed:@"icon_user_default"]

#define appUserCenter           [SEUserCenter defaultSession]
#define appConfig               [AppConfig defaultSession]

// 单例
#define SingletonH + (instancetype)shared;
#define SingletonM \
static id _instance; \
+ (instancetype)allocWithZone:(struct _NSZone *)zone \
{ \
    static dispatch_once_t onceToken; \
    dispatch_once(&onceToken, ^{ \
        _instance = [super allocWithZone:zone]; \
    }); \
    return _instance; \
} \
+ (instancetype)shared \
{ \
    static dispatch_once_t onceToken; \
    dispatch_once(&onceToken, ^{ \
        _instance = [[self alloc] init]; \
    }); \
    return _instance; \
} \
- (id)copyWithZone:(NSZone *)zone \
{ \
    return _instance; \
}

#define playStatusArray                 @[WSLocalized(@"顺序播放"), WSLocalized(@"循环播放"), WSLocalized(@"单曲循环"), WSLocalized(@"随机播放")]
#define languageArray                   @[@"zh-Hant", @"en"]
#define languageStrArray                @[@"繁体中文", @"English"]

#define WSLocalized(key)        NSLocalizedString(key, nil)
#endif /* SEMacro_h */
